package com.lc202407;

import java.util.HashMap;

public class Solution1941 {
    public boolean areOccurrencesEqual(String s) {
        HashMap<Character, Integer> map = new HashMap<>();
        for (int i = 0; i < s.length(); i++) {
            char key = s.charAt(i);
            int count = map.getOrDefault(key, 0) + 1;
            map.put(key, count);
        }
        int total = 0;
        for (Integer value : map.values()) {
            if (total == 0) {
                total = value;
                continue;
            }
            if (total != value) {
                return false;
            }
        }
        return true;
    }
}
